﻿using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Text;

namespace CodeLibrary.Net.Utils
{
    public static class EmailUtils
    {
        public static void SendMessage(string subject, string messageBody, string fromAddress, string toAddress, string ccAddress)
        {
            MailMessage message = new MailMessage();
            SmtpClient client = new SmtpClient();
            message.From = new MailAddress(fromAddress);
            if (toAddress.Trim().Length > 0)
            {
                foreach (string addr in toAddress.Split(';'))
                {
                    message.To.Add(new MailAddress(addr));
                }
            }
            if (ccAddress.Trim().Length > 0)
            {
                foreach (string addr in ccAddress.Split(';'))
                {
                    message.CC.Add(new MailAddress(addr));
                }
            }
            message.Subject = subject;
            message.Body = messageBody;
            client.Host = "YourMailServer";
            client.Send(message);
        }
    }
}
